import { createContext, PropsWithChildren, useState } from 'react'

export const LoginContext = createContext({
	agree: false,
	toggleAgree: () => {},
	confirmDilogVisible: false,
	openConfirmDialog: () => {},
	closeConfirmfDialog: () => {}
})

export const LoginContextProvider = ({ children }: PropsWithChildren) => {
	const [agree, setAgree] = useState(false)
	const [showConfirmDialog, onShowConfirmDialog] = useState(false)
	return (
		<LoginContext.Provider
			value={{
				agree,
				toggleAgree: () => {
					setAgree(!agree)
				},
				confirmDilogVisible: showConfirmDialog,
				openConfirmDialog: () => {
					onShowConfirmDialog(true)
				},
				closeConfirmfDialog: () => {
					onShowConfirmDialog(false)
				}
			}}
		>
			{children}
		</LoginContext.Provider>
	)
}
